package com.hexacta.hrs.web.struts.plugins;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.config.ForwardConfig;
import org.apache.struts.plugins.ModuleConfigVerifier;

/**
 * This class was created in order to avoid send an error email about a wrong
 * validation for the struts-config.xml file.
 * 
 * @author vschimpf
 * 
 */
public class ModuleConfigVerifierForTiles extends ModuleConfigVerifier {

	private static Log LOG = LogFactory.getLog(ModuleConfigVerifier.class);

	/**
	 * This method was overridden in order to skip a wrong validation over some
	 * paths for struts 1 in the struts-config file
	 */
	@Override
	protected boolean verifyForwardConfigs() {
		boolean ok = true;
		ForwardConfig[] fcs = config.findForwardConfigs();

		for (int i = 0; i < fcs.length; i++) {
			String path = fcs[i].getPath();

			if (path == null) {
				LOG.error(servlet.getInternal().getMessage(
						"verifyForwardConfigs.missing", fcs[i].getName()));
				ok = false;
			}
			// This validation doesn't works when referencing a tile in the
			// forward path.
			/*
			 * else if (!path.startsWith("/")) {
			 * LOG.error(servlet.getInternal().
			 * getMessage("verifyForwardConfigs.invalid", path,
			 * fcs[i].getName())); }
			 */
		}

		return (ok);
	}

}
